<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    <input type="button" value="POST请求" onclick="clickPost()"><br>
    <input type="button" value="GET请求" onclick="clickGET()"><br>
    <script type="text/javascript">
        function clickPost() {
            var param={"username":"tom","password":"123456","nikename":"admin"}
            $.ajax({
                type:"POST",
                url:"/user/testPost",
                data:JSON.stringify(param),
                contentType:"application/json",
                success:function (data) {
                    alert(data)
                },
                error:function (data) {
                    console.log(data)
                }
            })
        }
        function clickGET() {

            $.ajax({
                type:"GET",
                url:"/user/testGet",
                contentType:"application/json",
                success:function (data) {
                    console.log(data);
                },
                error:function (data) {
                    console.log(data);
                }
            })
        }
    </script>
</body>
</html>